package edu.zzuli.model.xt.jqqx.zzjggl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.springframework.stereotype.Controller;

import edu.zzuli.common.MisException;
import edu.zzuli.common.MyVisit;
import edu.zzuli.model.orm.po.GG_CZLB;
import edu.zzuli.model.xt.jqqx.zzjggl.iface.ZzjgglService;

/**
 * @author tianshaojie
 * @date 2011-8-25
 * @discription : 
 */
@Controller
public class JgryGnsqAction {
	
	@Resource
	private ZzjgglService zzjgglService;
	
	private String czyid;
	
	private String jgbh;
	
	private List selectedCzlb;
	
	private List<GG_CZLB> gridModel;
	
	private String ajaxResult;
	
	public String execute() {
		ServletActionContext.getRequest().getParameter("jgbh");
		ServletActionContext.getRequest().getParameter("czyid");
		if (this.jgbh == null || this.jgbh.length() == 0) {
			MyVisit myVisit = (MyVisit) ServletActionContext. getRequest().getSession().getAttribute("myVisit");
			this.jgbh = myVisit.getGG_JGBH().getJgbh();
		}
		return "success";
	}
	
	public String getResultDatas() {
		try {
			this.selectedCzlb = new ArrayList();
			this.setGridModel(zzjgglService.getCzlbList(this.jgbh,this.czyid,this.selectedCzlb));
			ajaxResult =  "success";
		} catch (MisException e) {
			e.printStackTrace();
			ajaxResult =  "error";
		} catch (Exception e) {
			e.printStackTrace();
			ajaxResult =  "error";
		}
		return ajaxResult;
	}
	
	public String save() {
		try {
			String ids = ServletActionContext.getRequest().getParameter("ids");	
			zzjgglService.saveJgryQx(this.czyid, ids);
			ajaxResult =  "success";
		} catch (MisException e) {
			e.printStackTrace();
			ajaxResult =  "error";
		} catch (Exception e) {
			e.printStackTrace();
			ajaxResult =  "error";
		}
		return ajaxResult;
	}
	
	public void setAjaxResult(String ajaxResult) {
		this.ajaxResult = ajaxResult;
	}

	public String getAjaxResult() {
		return ajaxResult;
	}

	public String getCzyid() {
		return czyid;
	}

	public String getJgbh() {
		return jgbh;
	}

	public List<GG_CZLB> getSelectedCzlb() {
		return selectedCzlb;
	}

	public void setCzyid(String czyid) {
		this.czyid = czyid;
	}

	public void setJgbh(String jgbh) {
		this.jgbh = jgbh;
	}

	public void setSelectedCzlb(List<GG_CZLB> selectedCzlb) {
		this.selectedCzlb = selectedCzlb;
	}
	
	public void setGridModel(List<GG_CZLB> gridModel) {
		this.gridModel = gridModel;
	}

	public List<GG_CZLB> getGridModel() {
		return gridModel;
	}
}
